#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

int main()
{
    int a[100], n, i;
    //Enter the number of the elements you want to input(smaller than 100)
    printf ("How many elements do you want to input(<100) :");
    scanf ("%d", &n);
    
    //Enter the value for each element(from a[0] to a[n-1] by using for loop with variable i in the index a[i])
    for (i=0; i<n; i++)
    {
        printf ("Enter a[%d] :", i);
        scanf ("%d", &a[i]);
        }   
     system("cls");
     bubble (a, n); 
     printf("\nSorted elements is :");
     for(i=0; i<n; i++)
              printf(" %d", a[i]);
     
     getch();
}

int bubble (int a[], int n)
{
    int i, j;
    for (i=n-1; i>0; i--)
    {
        for(j=0; j<i; j++)
        {
                 if(a[j] > a[j+1])
                  swap (&a[j], &a[j+1]);
        }   
    }
}

  int swap(int *a, int *b)
                  {
                         int temp;
                         temp=*a;
                         *a=*b;
                         *b=temp;
                         }
